home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / share / perl5 / GnuPG / Revoker.pm < prev    next >
Encoding:
Perl POD Document  |  2010-06-05  |  3.8 KB  |  159 lines

  1. #  Revoker.pm
  2. #    - providing an object-oriented approach to GnuPG key revokers
  3. #
  4. #  Copyright (C) 2010 Daniel Kahn Gillmor <dkg@fifthhorseman.net>
  5. #  (derived from Signature.pm, Copyright (C) 2000 Frank J. Tobin <ftobin@cpan.org>)
  6. #
  7. #  This module is free software; you can redistribute it and/or modify it
  8. #  under the same terms as Perl itself.
  9. #
  10. #  This program is distributed in the hope that it will be useful,
  11. #  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. #
  14. #  $Id: Signature.pm,v 1.4 2001/08/21 13:31:50 ftobin Exp $
  15. #
  16.  
  17. package GnuPG::Revoker;
  18. use Any::Moose;
  19.  
  20. has [qw(
  21.          algo_num
  22.          class
  23.       )] => (
  24.     isa => 'Int',
  25.     is  => 'rw',
  26. );
  27.  
  28. has fingerprint => (
  29.                     isa => 'GnuPG::Fingerprint',
  30.                     is => 'rw',
  31.                     );
  32.  
  33. has signatures => (
  34.     isa       => 'ArrayRef',
  35.     is        => 'rw',
  36.     default   => sub { [] },
  37. );
  38.  
  39. sub push_signatures {
  40.     my $self = shift;
  41.     push @{ $self->signatures }, @_;
  42. }
  43.  
  44. sub is_sensitive {
  45.     my $self = shift;
  46.     return $self->class & 0x40;
  47. }
  48.  
  49. sub compare {
  50.   my ( $self, $other, $deep ) = @_;
  51.  
  52.   my @comparison_ints = qw( class algo_num );
  53.  
  54.   foreach my $field ( @comparison_ints ) {
  55.     return 0 unless $self->$field() == $other->$field();
  56.   }
  57.  
  58.   return 0 unless $self->fingerprint->compare($other->fingerprint);
  59.  
  60.   # FIXME: is it actually wrong if the associated signatures come out
  61.   # in a different order on the two compared designated revokers?
  62.   if (defined $deep && $deep) {
  63.     return 0 unless @{$self->signatures} == @{$other->signatures};
  64.     for ( my $i = 0; $i < scalar(@{$self->signatures}); $i++ ) {
  65.       return 0
  66.         unless $self->signatures->[$i]->compare($other->signatures->[$i], 1);
  67.     }
  68.   }
  69.  
  70.   return 1;
  71. }
  72.  
  73. __PACKAGE__->meta->make_immutable;
  74.  
  75. 1;
  76.  
  77. __END__
  78.  
  79. =head1 NAME
  80.  
  81. GnuPG::Revoker - GnuPG Key Revoker Objects
  82.  
  83. =head1 SYNOPSIS
  84.  
  85.   # assumes a GnuPG::PrimaryKey object in $key
  86.   my $revokerfpr = $key->revokers->[0]->fingerprint();
  87.  
  88. =head1 DESCRIPTION
  89.  
  90. GnuPG::Revoker objects are generally not instantiated on their own,
  91. but rather as part of GnuPG::Key objects.  They represent a statement
  92. that another key is designated to revoke certifications made by the
  93. key in question.
  94.  
  95. =head1 OBJECT METHODS
  96.  
  97. =over 4
  98.  
  99. =item new( I<%initialization_args> )
  100.  
  101. This methods creates a new object.  The optional arguments are
  102. initialization of data members.
  103.  
  104. =item is_sensitive()
  105.  
  106. Returns 0 if the revoker information can be freely distributed.
  107. If this is non-zero, the information should be treated as "sensitive".
  108.  
  109. Please see http://tools.ietf.org/html/rfc4880#section-5.2.3.15 for
  110. more explanation.
  111.  
  112. =item compare( I<$other>, I<$deep> )
  113.  
  114. Returns non-zero only when this designated revoker is identical to the
  115. other GnuPG::Revoker.  If $deep is present and non-zero, the revokers'
  116. signatures will also be compared.
  117.  
  118.  
  119. =back
  120.  
  121. =head1 OBJECT DATA MEMBERS
  122.  
  123. =over 4
  124.  
  125. =item fingerprint
  126.  
  127. A GnuPG::Fingerprint object indicating the fingerprint of the
  128. specified revoking key.  (Note that this is *not* the fingerprint of
  129. the key whose signatures can be revoked by this revoker).
  130.  
  131. =item algo_num
  132.  
  133. The numeric identifier of the algorithm of the revoker's key.
  134.  
  135. =item signatures
  136.  
  137. A list of GnuPG::Signature objects which cryptographically bind the
  138. designated revoker to the primary key.  If the material was
  139. instantiated using the *_with_sigs() functions from GnuPG::Interface,
  140. then a valid revoker designation should have a valid signature
  141. associated with it from the relevant key doing the designation (not
  142. from the revoker's key).
  143.  
  144. Note that designated revoker certifications are themselves
  145. irrevocable, so there is no analogous list of revocations in a
  146. GnuPG::Revoker object.
  147.  
  148. =back
  149.  
  150. =head1 SEE ALSO
  151.  
  152. L<GnuPG::Interface>,
  153. L<GnuPG::Fingerprint>,
  154. L<GnuPG::Key>,
  155. L<GnuPG::Signature>,
  156. L<http://tools.ietf.org/html/rfc4880#section-5.2.3.15>
  157.  
  158. =cut
  159.